package com.xdh.springcloud.common.message;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.HashMap;
import java.util.Map;


public class Message {

    private int code;

    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String msg;

    private Map<String, Object> data;

    public Message() {
    }

    public Message(MessageCode messageCode, String msg) {
        this.code = messageCode.getCode();
        this.msg = msg;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }


    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public boolean addData(String key, Object v) {
        if (this.data == null) {
            this.data = new HashMap<>();
        }
        this.data.put(key, v);
        return true;
    }
}
